/**
 * 
 */
package com.jeesuite.demo.rest;

import com.jeesuite.demo.exception.DemoBaseException;
import com.jeesuite.rest.BaseApplicaionConfig;
import com.jeesuite.rest.excetion.ExcetionWrapper;
import com.jeesuite.rest.response.WrapperResponseEntity;


public class ApplicationConfig extends BaseApplicaionConfig {


	@Override
	public ExcetionWrapper createExcetionWrapper() {
		return new demoExcetionWrapper();
	}


	@Override
	public String packages() {
		return "com.jeesuite.demo.rest";
	}
	
	public static class demoExcetionWrapper implements ExcetionWrapper{

		@Override
		public WrapperResponseEntity toResponse(Exception e) {
			if(e instanceof DemoBaseException){
				DemoBaseException ex = (DemoBaseException) e;
				return new WrapperResponseEntity(ex.getCode() + "", ex.getMessage(), true);
			}
			// 
			return null;
		}
		
	}
	
}
